package com.huawei.appmarket.service.distribution.deeplink.fulldetail;

import android.text.TextUtils;
import androidx.annotation.NonNull;
import com.huawei.appgallery.foundation.service.common.protocol.AppListFragmentProtocol;
import com.huawei.appgallery.foundation.service.common.protocol.request.AppListFragmentRequest;
import com.huawei.appgallery.foundation.ui.framework.cardframe.fragment.TaskFragment;
import com.huawei.appgallery.foundation.ui.framework.cardframe.fragment.TaskFragment.b;
import com.huawei.appgallery.foundation.ui.framework.uikit.ContractFragment;
import com.huawei.appgallery.serverreqkit.api.bean.ResponseBean;
import com.huawei.appmarket.R;
import com.huawei.appmarket.framework.AppDetailActivity;
import com.huawei.appmarket.service.appdetail.bean.detail.DetailHeadBean;
import com.huawei.appmarket.service.appdetail.bean.detail.DetailHiddenBean;
import com.huawei.appmarket.service.distribution.authentication.bean.AgdSecurityVerificationRequest;
import com.huawei.appmarket.service.distribution.authentication.bean.AgdSecurityVerificationResponse;
import com.huawei.appmarket.service.distribution.deeplink.fulldetail.DisFullDetailActivityProtocol.Request;
import java.util.LinkedHashMap;
import java.util.List;
import o.cfv;
import o.cin;
import o.cjk;
import o.cjm;
import o.cjo;
import o.cvt;
import o.BaseRequest;
import o.dgh;
import o.dmt;
import o.Logger;
import o.drj;
import o.drr;
import o.dxq;
import o.CollectCheck;
import o.FragmentTransaction;
import org.json.JSONException;
import org.json.JSONObject;

public class DisFullDetailActivity extends AppDetailActivity<DisFullDetailActivityProtocol> {
    private boolean ˏॱ = false;

    private boolean ˊᐝ() {
        return (ʾ() == null || ((DisFullDetailActivityProtocol) ʾ()).ˋ() == null) ? false : true;
    }

    public void ˎ(TaskFragment taskFragment, List<cvt> list) {
        if (ˊᐝ()) {
            Object ˎˎ = ((DisFullDetailActivityProtocol) ʾ()).ˋ().ˎˎ();
            if (!TextUtils.isEmpty(ˎˎ)) {
                ResponseBean agdSecurityVerificationResponse = new AgdSecurityVerificationResponse();
                try {
                    agdSecurityVerificationResponse.fromJson(new JSONObject(ˎˎ));
                    agdSecurityVerificationResponse.setResponseCode(0);
                    dxq.ˏ(agdSecurityVerificationResponse);
                    BaseRequest o_cfv = new cfv();
                    this.ˏॱ = true;
                    ˋ(taskFragment, new b(o_cfv, agdSecurityVerificationResponse));
                    return;
                } catch (JSONException e) {
                    Logger.ˎ("DisFullDetailActivity", "convert json error: JSONException");
                } catch (IllegalAccessException e2) {
                    Logger.ˎ("DisFullDetailActivity", "convert json error: IllegalAccessException");
                } catch (InstantiationException e3) {
                    Logger.ˎ("DisFullDetailActivity", "convert json error: InstantiationException");
                } catch (ClassNotFoundException e4) {
                    Logger.ˎ("DisFullDetailActivity", "convert json error: ClassNotFoundException");
                }
            }
        }
        super.ˎ(taskFragment, list);
    }

    public void ͺ() {
        if (!this.ˏॱ) {
            super.ͺ();
        }
    }

    public cfv ᐝ() {
        if (ˊᐝ()) {
            return AgdSecurityVerificationRequest.ˏ(((DisFullDetailActivityProtocol) ʾ()).ˋ());
        }
        return AgdSecurityVerificationRequest.ˏ(new Request());
    }

    public boolean ˋ(TaskFragment taskFragment, b bVar) {
        if (bVar.ˋ.getResponseCode() != 0 || bVar.ˋ.getRtnCode_() != 0) {
            return super.ˋ(taskFragment, bVar);
        }
        drr o_drr = new drr();
        drr.ˊ(o_drr, new cfv(), bVar.ˋ);
        DetailHeadBean ˋ = o_drr.ˋ();
        DetailHiddenBean ᐝ = o_drr.ᐝ();
        if (ˋ == null || ᐝ == null || CollectCheck.isEmpty(o_drr.ʽ())) {
            ˎ(bVar);
            return false;
        }
        ˏ(ᐝ);
        if (ˊᐝ()) {
            ((cfv) bVar.ˊ).ˏ(drj.ˏ(((DisFullDetailActivityProtocol) ʾ()).ˋ().ˊˊ()));
        }
        return super.ˋ(taskFragment, bVar);
    }

    private void ˏ(@NonNull DetailHiddenBean detailHiddenBean) {
        DisFullDetailActivityProtocol disFullDetailActivityProtocol = (DisFullDetailActivityProtocol) ʾ();
        if (disFullDetailActivityProtocol != null) {
            Request ˋ = disFullDetailActivityProtocol.ˋ();
            if (ˋ != null) {
                LinkedHashMap linkedHashMap = new LinkedHashMap();
                linkedHashMap.put("detailId", detailHiddenBean.ॱॱ());
                linkedHashMap.put("accessID", ˋ.ᐝ());
                linkedHashMap.put("detailType", ˋ.ˋˊ());
                if (!TextUtils.isEmpty(ˋ.ॱˎ())) {
                    linkedHashMap.put("referrer", dmt.ˊ(ˋ.ॱˎ()).get("referrer"));
                }
                dgh.ˋ("380701", linkedHashMap);
            }
        }
    }

    private void ˎ(b bVar) {
        cjo appListFragmentProtocol = new AppListFragmentProtocol();
        AppListFragmentRequest appListFragmentRequest = new AppListFragmentRequest();
        appListFragmentRequest.ʻ(true);
        appListFragmentRequest.ॱ(true);
        appListFragmentProtocol.ˏ(appListFragmentRequest);
        ContractFragment contractFragment = (ContractFragment) cjk.ˎ().ˊ(new cjm("appdetailoffshelve.fragment", appListFragmentProtocol));
        cin o_cin = (cin) contractFragment.ˊ(cin.class);
        if (o_cin != null) {
            o_cin.ॱ(bVar);
        }
        try {
            FragmentTransaction ˊ = ˏॱ().ˊ();
            ˊ.ˏ(R.id.app_detail_container, contractFragment, "AppDetail");
            ˊ.ˋ();
        } catch (ArrayIndexOutOfBoundsException e) {
            Logger.ˋ("DisFullDetailActivity", e.toString());
        }
    }

    public void ᐝॱ() {
        onBackPressed();
    }

    public void onBackPressed() {
        Logger.ˎ("DisFullDetailActivity", "onBackPressed");
        super.onBackPressed();
        if (!isFinishing()) {
            Logger.ˎ("DisFullDetailActivity", "execute finish");
            finish();
        }
        cjm o_cjm = new cjm("market.activity", null);
        o_cjm.ॱ().addFlags(268468224);
        cjk.ˎ().ˋ(getApplicationContext(), o_cjm);
    }
}
